<?php

/**
 * class Controller
 * класс-родитель для всех контроллеров страниц
 */
abstract class Controller{
    protected $model;
    protected $view;
    private $registry;
    private $context;
    private $status = OK;

    abstract function onCreatePage();

    public function getArgs() {
        return $this->context->getArgs();
    }
    public function getContext() {
        return $this->context;
    }
    public function getStatus() {
        return $this->status;
    }
    public function setStatus($status) {
        $this->status = $status;
    }
    public function getView() {
        return $this->view;
    }
    public function getFormManager() {
        return $this->registry->form_manager;
    }
    protected function output($pagedata) {
            $this->themeunit->add(array('html'=>array($pagedata)));
    }
    public function __get($key) {
        return $this->registry->get($key);
    }
    public function __set($key, $value) {
        $this->registry->set($key, $value);
    }
    public function __construct(RequestContext $context) {
        $this->registry = Registry::getInstance();
        $this->context = $context;
        $this->view = new View($context);

    }


//    function render($args = array(), $template_name = 'base' , $type = 'current', $folder = 'current') {
//
//        if ($type=='current') {
//            if (get_parent_class($this) == 'AbstractModule') {
//                $type = 'module';
//            } elseif (get_parent_class($this) == 'AbstractComponent') {
//                $type = 'component';
//            }
//        }
//        if($folder == 'current')
//        {
//            $folder = get_class($this);
//            $folder = preg_replace("/Controller/ui", "", $folder);
//        }
//
//        $view = new View($this);
//    
//        return $view->getHTML($template_name, $args, $type, $folder);
//
//    }



}
?>
